function longestCommonPrefix(strs: string[]): string {
    let comStr: string = '';
    let ss = strs[0];
    
    if(strs.length === 1){
        comStr = strs[0];
        return comStr;
    }
    
    for(let i = 1 ;i<strs.length;i++){
        // for(let j = 0; j < strs[i].length;j++){
        //     if(ss[j] === strs[i][j]){
        //         // 不包含的时候才会加入
        //         if(!comStr.includes(ss[j])){
        //             comStr+=ss[j];
        //         }
        //     }else{
        //         comStr = comStr.replace(ss[j],'');
        //     }
        // }
        let j=0;
        for(;j<strs[i].length&&j<ss.length;j++){
            if(ss[j] !== strs[i][j]){
                break
            }
        }
        ss = ss.substring(0,j);
    }
    return ss;
};

let strs = ["flower","flow","flight"];
let s = ['a'];
let ss = ["cir","car"];
let sss = ["flower","flow","flight"];
let comStr = longestCommonPrefix(ss);
let comStr1 = longestCommonPrefix(sss);
console.log(comStr);
console.log(comStr1);